import java.util.InputMismatchException;
import java.util.Scanner;

/**
 * @Author 12629
 * @Description：
 */
public class Test {




    public static void funcction() throws ArrayIndexOutOfBoundsException{
        int[] arr = {1, 2, 3};
        System.out.println(arr[100]);
    }

    public static void main(String[] args) {
        try {
            funcction();
        }catch (ArrayIndexOutOfBoundsException e) {

        }finally {

        }


    }



    public static int getData() {
        Scanner sc = null;
        try {
            sc = new Scanner(System.in);
            int data = sc.nextInt();
            return data;
        } catch (InputMismatchException e) {
            e.printStackTrace();
        } finally {
            System.out.println("finally中代码");
        }


        System.out.println("try-catch-finally之后代码");
        if (null != sc) {
            sc.close();
        }
        return 0;
    }

    public static void main11111(String[] args) {
        int data = getData();
        System.out.println(data);
    }
    public static int func() {
        Scanner scanner = new Scanner(System.in);
        try {
            return 10;
        }catch (NullPointerException e) {
            System.out.println("捕获到了一个空指针异常！");
        }finally {
            //一般用来 释放资源
            scanner.close();
            System.out.println("这里执行了finally，一定会被执行！");
        }
        return 100;
    }
    public static int func2() {

        try (Scanner scanner = new Scanner(System.in)) {
            return 10;
        } catch (NullPointerException e) {
            System.out.println("捕获到了一个空指针异常！");
        } finally {
            //一般用来 释放资源
            System.out.println("这里执行了finally，一定会被执行！");
        }
        return 100;
    }


    public static void main11(String[] args) {
        System.out.println(func());
    }

    public void merge(int A[], int m, int B[], int n) {
        int i = m-1;
        int j = n-1;
        int k = m+n-1;
        //这样才能保证两个数组里面都有数据
        while (i >= 0 && j >= 0) {
            if(A[i] < B[j]) {
                /*A[k] = B[j];
                j--;
                k--;*/
                A[k--] = B[j--];
            }else {
                A[k--] = A[i--];
            }
        }
        //有一个没有元素了
        while (j >= 0) {
            A[k--] = B[j--];
        }
        while (i >= 0) {
            A[k--] = A[i--];
        }
    }







    //abccbd
    public static String func(String str) {
        //默认是false
        boolean[] flgs = new boolean[127];
        StringBuilder stringBuilder = new StringBuilder();
        for (int i = 0; i < str.length(); i++) {
            char ch = str.charAt(i);
            if(!flgs[ch]) {
                stringBuilder.append(ch);
                flgs[ch] = true;
            }
        }
        return stringBuilder.toString();
    }

    public static void main1(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextLine()) { // 注意 while 处理多个 case
            String str = in.nextLine();
            String ret = func(str);
            System.out.println(ret);
        }
    }


}
